/* Copyright (C) 2011 clueless <clueless.mmopeon@gmail.com>
 *
 * This file is part of MMO Peon.
 *
 * MMO Peon is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * MMO Peon is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with MMO Peon.  If not, see <http://www.gnu.org/licenses/>.
 */

#ifndef __MMOPEON_OBJECTMAP_H
#define __MMOPEON_OBJECTMAP_H
#include <cstdint>
#include <map>
#include "../commontypes.h"
#include <string>
#include <vector>


struct GameObject
{
    uint32_t            objectId;
    uint32_t            objectId2;
    uint32_t            objectType;
    std::string         name;
    struct RomCoords    coords;
};

typedef std::map<uint32_t, GameObject> ObjectMapData;

class ObjectMap
{
    public:
        ObjectMap(bool obtain = false);
        ObjectMap(const ObjectMap& source);
        ~ObjectMap();
        ObjectMap& operator=(const ObjectMap& source);

        size_t Count() const;
        bool HasObject(uint32_t objectId) const;
        void Delete(uint32_t objectId);
        void Add(const GameObject &object);
        void Update(const GameObject &object);
        GameObject* Get(uint32_t objectId);
        ObjectMap Filter(uint32_t objectType) const;
        ObjectMap Filter(float distance, const RomCoords &coords) const;
        ObjectMapData::iterator Begin();
        ObjectMapData::iterator End();

    private:
        bool obtained;
        ObjectMapData *data;
};

bool ObjectMapInit();
void ObjectMapFree();
#endif
